package com.delos.rest.controller;

import com.delos.api.manager.IRedisManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Redis测试
 *
 * @author zouyaowen
 * @date 2020-05-17
 */
@RestController
@RequestMapping("/redis")
@Slf4j
@Api(tags = "Redis接口")
public class RedisController {
    @Autowired
    private IRedisManager redisManager;

    @ApiOperation("getData请求")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key", value = "key", dataTypeClass = String.class)
    })
    @GetMapping("/getData")
    public String getData(String key) {
        return redisManager.getData(key);
    }

    @ApiOperation("setData请求")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key", value = "key", dataTypeClass = String.class),
            @ApiImplicitParam(name = "value", value = "value", dataTypeClass = String.class)
    })
    @PostMapping("/setData")
    public void setData(String key, String value) {
        redisManager.setData(key, value);
    }
}
